<template>
  <x-border ref="xBorder">
    <x-table type="Article" ref="xTable" @afterTableLoad="afterTableLoad"></x-table>
  </x-border>
</template>

<script>
  import './var.scss'

  import ala from 'ala'
  export default {
    data () {
      return {
      }
    },
    props: {
      widget: {}
    },
    mounted () {
      this.init()
    },
    methods: {
      async init () {
        this.type = this.$ala.urlType()
        if (this.$route.query.ChannelId === undefined) {
          this.$ala.error('网址输入不正确，cms访问时请输入相关的ChannelId')
        }
        var channelResponse = await this.$ala.httpGet('api/Channel/ViewById', { Id: this.$route.query.ChannelId })
        if (channelResponse) {
          this.$nextTick(() => {
            if (this.$refs.xBorder) {
              this.$refs.xBorder.changeStyle(channelResponse.name)
            }
          })
        }
      },
      // 表格加载完成事件
      afterTableLoad (dataResult) {
      },
      watchWidget (val) {
        this.init()
        this.$nextTick(() => {
          this.$refs.xTable.init('Article')
        })
      }
    },
    watch: {
      $route: 'watchWidget'
    }
  }
</script>
